|
1
|
|
|
var PBSyntaxHighlighter = (function() { |
|
2
|
|
|
"use strict"; |
|
3
|
|
|
|
|
4
|
|
|
var sh; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Constructor |
|
8
|
|
|
* @param {String} sh The SyntaxHighlighter |
|
9
|
|
|
*/ |
|
10
|
|
|
function PBSyntaxHighlighter(sh) { |
|
11
|
|
|
switch (sh) { |
|
12
|
|
|
case "HIGHLIGHT" : |
|
13
|
|
|
this.sh = HIGHLIGHT; |
|
14
|
|
|
break; |
|
15
|
|
|
case "PRETTIFY" : |
|
16
|
|
|
this.sh = PRETTIFY; |
|
17
|
|
|
break; |
|
18
|
|
|
case "PRISM" : |
|
19
|
|
|
this.sh = PRISM; |
|
20
|
|
|
break; |
|
21
|
|
|
case "SYNTAX_HIGHLIGHTER" : |
|
22
|
|
|
this.sh = SYNTAX_HIGHLIGHTER; |
|
23
|
|
|
break; |
|
24
|
|
|
default : |
|
25
|
|
|
this.sh = { |
|
26
|
|
|
_type: "DEFAULT", |
|
27
|
|
|
_cls: "", |
|
28
|
|
|
_tag: 'pre' |
|
29
|
|
|
}; |
|
30
|
|
|
break; |
|
31
|
|
|
} |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Sets the SyntaxHighlighter type |
|
36
|
|
|
* @param {String} type The name of the SyntaxHighlighter |
|
37
|
|
|
*/ |
|
38
|
|
|
PBSyntaxHighlighter.prototype.setType = function(type) { |
|
39
|
|
|
this.sh._type = type; |
|
40
|
|
|
}; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Gets the SyntaxHighlighter type |
|
44
|
|
|
* @return {String} The type of the SyntaxHighlighter |
|
45
|
|
|
*/ |
|
46
|
|
|
PBSyntaxHighlighter.prototype.getType = function() { |
|
47
|
|
|
return this.sh._type; |
|
48
|
|
|
}; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Sets the full class of the SH object |
|
52
|
|
|
* @param {String} cls the class to add to the Object |
|
53
|
|
|
*/ |
|
54
|
|
|
PBSyntaxHighlighter.prototype.setCls = function(cls) { |
|
55
|
|
|
this.sh.cls = this.sh._cls + cls; |
|
56
|
|
|
}; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Gets the full class of the SH Object |
|
60
|
|
|
* @return {String} the full class of the SH Object |
|
61
|
|
|
*/ |
|
62
|
|
|
PBSyntaxHighlighter.prototype.getCls = function() { |
|
63
|
|
|
return this.sh.cls; |
|
64
|
|
|
}; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Get the tag to insert into the pre tag |
|
68
|
|
|
* @return {String} the tag to insert, pre otherwise |
|
69
|
|
|
*/ |
|
70
|
|
|
PBSyntaxHighlighter.prototype.getTag = function() { |
|
71
|
|
|
return this.sh._tag; |
|
72
|
|
|
}; |
|
73
|
|
|
|
|
74
|
|
|
return PBSyntaxHighlighter; |
|
75
|
|
|
})(); |
|
76
|
|
|
|
|
77
|
|
|
/**********************************/ |
|
78
|
|
|
/* SYNTAX HIGHLIGHTERS DEFINITION */ |
|
79
|
|
|
/**********************************/ |
|
80
|
|
|
var HIGHLIGHT = { |
|
81
|
|
|
_type: "HIGHLIGHT", |
|
82
|
|
|
_cls: "", // only show language (done in pbckcode.js) |
|
83
|
|
|
_tag: 'code' |
|
84
|
|
|
}; |
|
85
|
|
|
|
|
86
|
|
|
var PRETTIFY = { |
|
87
|
|
|
_type: "PRETTIFY", |
|
88
|
|
|
_cls: "prettyprint linenums lang-", |
|
89
|
|
|
_tag: 'pre' |
|
90
|
|
|
}; |
|
91
|
|
|
|
|
92
|
|
|
var PRISM = { |
|
93
|
|
|
_type: "PRISM", |
|
94
|
|
|
_cls: "language-", |
|
95
|
|
|
_tag: 'code' |
|
96
|
|
|
}; |
|
97
|
|
|
|
|
98
|
|
|
var SYNTAX_HIGHLIGHTER = { |
|
99
|
|
|
_type: "SYNTAX_HIGHLIGHTER", |
|
100
|
|
|
_cls: "brush: ", |
|
101
|
|
|
_tag: 'pre' |
|
102
|
|
|
}; |
|
103
|
|
|
|